package com.jprocms.module.cms.controller.admin.task.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.time.OffsetDateTime;

import static com.jpro.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

/**
 * 任务 Base VO，提供给添加、修改、详细的子 VO 使用
 * 如果子 VO 存在差异的字段，请不要添加到这里，影响 Swagger 文档生成
 */
@Data
public class TaskBaseVO {

    @Schema(description = "站点ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2168")
    @NotNull(message = "站点ID不能为空")
    private Long siteId;

    @Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "8147")
    @NotNull(message = "用户ID不能为空")
    private Long userId;

    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
    @NotNull(message = "名称不能为空")
    private String name;

    @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "开始时间不能为空")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private OffsetDateTime beginTime;

    @Schema(description = "结束时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private OffsetDateTime endTime;

    @Schema(description = "已完成数量", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "已完成数量不能为空")
    private Integer currentNum;

    @Schema(description = "总数量", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "总数量不能为空")
    private Integer totalNum;

    @Schema(description = "类型(1:HTML生成,2:全文索引生成)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @NotNull(message = "类型(1:HTML生成,2:全文索引生成)不能为空")
    private Short taskType;

    @Schema(description = "状态(0:等待,1:运行中,2:出错,3:停止,4:完成)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
    @NotNull(message = "状态(0:等待,1:运行中,2:出错,3:停止,4:完成)不能为空")
    private Short status;

    @Schema(description = "错误信息")
    private String errorMsg;

}
